<table id ='tables'>
<tr>
<th rowspan=2>STT</th>
<th rowspan=2>Đơn vị</th>
<th rowspan=2>Nhân viên</th>
<th rowspan=2>Đội</th>
<th rowspan=2>Địa Điểm</th>
<th rowspan=2>Ngày</th>
<th rowspan=2>Thành viên tham gia</th>
<th colspan=<?php $numhh = count($hanghoas);  echo $numhh?>>Chỉ tiêu</th>
<th rowspan=2>Ghi chú</th>
</tr>
<tr>
<?php foreach ($hanghoas as $keyhh =>$valhh):?>
<th><?php echo $valhh ?></th>
<?php endforeach;?>
</tr>
<?php
	$i=0; 
	 foreach ($chitieungays as $chitieungay):
	  $i++;
?>
<tr>
<td><?php echo $i?></td>
<td><?php echo $chitieungay['Nhanvien']['Donvi']['madv']?></td>
<td><?php echo $chitieungay['Nhanvien']['tennv']?></td>
<td><?php echo $chitieungay['Kehoachbhld']['tendoi']?></td>
<td><?php echo $chitieungay['Kehoachbhld']['diadiem']?></td>
<td><?php echo date('d-m-Y',strtotime($chitieungay['Kehoachbhld']['thoigian']))?></td>
<td><?php echo $chitieungay['Kehoachbhld']['nhansu']?></td>
<?php foreach ($hanghoas as $keyhh =>$valhh):?>
<td>
<?php
	foreach ($chitieungay['Chitieungay'] as $ctngay)
	{
		if($ctngay['hanghoa_id']==$keyhh)
 			echo $ctngay['soluong'];	
	}
?>
</td>
<?php endforeach;?>
<td><?php echo $chitieungay['Kehoachbhld']['ghichu']?></td>
</tr>
<?php endforeach;?> 
</table>